package cn.rongdao.jrkabao.model.cashadvance;

import android.os.Build;

import com.mifengkong.frtools.http.request.HttpFunction;
import com.mifengkong.frtools.util.FRDeviceUtil;
import com.mifengkong.frtools.util.FRString;

import java.util.Map;

import cn.rongdao.jrkabao.bean.cashadvance.CashPayPrepareBean;
import cn.rongdao.jrkabao.model.api.BaseKaMaoModel;
import cn.rongdao.jrkabao.util.NetWorkUtil;
import io.reactivex.Observable;
import io.reactivex.Observer;

/**
 * Created by jack on 2017/6/3
 */

public class CashPeyPrepareModel extends BaseKaMaoModel {

    public static CashPeyPrepareModel getInstance() {
        return getPresent(CashPeyPrepareModel.class);
    }

    public CashPeyPrepareModel addParams(String key, Object value) {
        if (!FRString.isEmpty(key)) {
            mParams.put(key, FRString.valueOf(value));
        }
        return this;
    }

    public CashPeyPrepareModel addParams(Map<String, String> map) {
        if (null != map && map.size() > 0) {
            mParams.putAll(map);
        }
        return this;
    }

    public void execute(Observer<CashPayPrepareBean> observer) {
        addParamStrings("dev_sys", FRString.valueOf(Build.VERSION.SDK_INT));
        addParamStrings("dev_no", FRDeviceUtil.getPhoneModels());
        addParamStrings("net_info", NetWorkUtil.getCurrentNetworkType());
        Observable<CashPayPrepareBean> observable = mServletApi.getCashPrepareData(mParams).map(new HttpFunction<CashPayPrepareBean>());
        toSubscribe(observable, observer);
    }

}